package com.alipay.api;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alipay.config.AlipayConfig;
import com.alipay.model.CreateDirectPayByUserWapReq;
import com.alipay.util.AlipaySubmit;

/**
 * 支付宝手机网站支付接口
 *
 */
public class CreateDirectPayByUserWapApi {

	public void execute(CreateDirectPayByUserWapReq req, HttpServletRequest request, HttpServletResponse response) throws IOException {
		
		//把请求参数打包成数组
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", AlipayConfig.create_direct_pay_by_user_service_wap);
        sParaTemp.put("partner", AlipayConfig.partner);
        sParaTemp.put("seller_id", AlipayConfig.seller_id);
        sParaTemp.put("_input_charset", AlipayConfig.input_charset);
		sParaTemp.put("payment_type", AlipayConfig.payment_type);
		sParaTemp.put("notify_url", AlipayConfig.notify_url_wap);
		sParaTemp.put("return_url", AlipayConfig.return_url_wap);
		sParaTemp.put("out_trade_no", req.getOut_trade_no());
		sParaTemp.put("subject", req.getSubject());
		sParaTemp.put("total_fee", req.getTotal_fee());
		sParaTemp.put("show_url", req.getShow_url());
		sParaTemp.put("app_pay","Y");//启用此参数可唤起钱包APP支付。
		sParaTemp.put("body", req.getBody());
		//其他业务参数根据在线开发文档，添加参数.文档地址:https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.2Z6TSk&treeId=60&articleId=103693&docType=1
        //如sParaTemp.put("参数名","参数值");
		
		//建立请求
		String sHtmlText = AlipaySubmit.buildRequest(sParaTemp,"get","确认");
		response.setContentType("text/html");
		response.getWriter().print(sHtmlText);
	}
}
